/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class ListLookupRequest
    {
    
        private Condition? conditionField;

        private DeliveryMethod? deliveryMethodField;

        private String ISPUPostalCodeField;

        private String listIdField;

        private String listTypeField;

        private String merchantIdField;

        private String productGroupField;

        private Decimal? productPageField;

        private List<String> responseGroupField;

        private String reviewSortField;

        private String sortField;


        /// <summary>
        /// Gets and sets the Condition property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Condition")]
        public Condition Condition
        {
            get { return this.conditionField.GetValueOrDefault() ; }
            set { this.conditionField= value; }
        }



        /// <summary>
        /// Sets the Condition property
        /// </summary>
        /// <param name="condition">Condition property</param>
        /// <returns>this instance</returns>
        public ListLookupRequest WithCondition(Condition condition)
        {
            this.conditionField = condition;
            return this;
        }



        /// <summary>
        /// Checks if Condition property is set
        /// </summary>
        /// <returns>true if Condition property is set</returns>
        public Boolean IsSetCondition()
        {
            return this.conditionField.HasValue;

        }


        /// <summary>
        /// Gets and sets the DeliveryMethod property.
        /// </summary>
        [XmlElementAttribute(ElementName = "DeliveryMethod")]
        public DeliveryMethod DeliveryMethod
        {
            get { return this.deliveryMethodField.GetValueOrDefault() ; }
            set { this.deliveryMethodField= value; }
        }



        /// <summary>
        /// Sets the DeliveryMethod property
        /// </summary>
        /// <param name="deliveryMethod">DeliveryMethod property</param>
        /// <returns>this instance</returns>
        public ListLookupRequest WithDeliveryMethod(DeliveryMethod deliveryMethod)
        {
            this.deliveryMethodField = deliveryMethod;
            return this;
        }



        /// <summary>
        /// Checks if DeliveryMethod property is set
        /// </summary>
        /// <returns>true if DeliveryMethod property is set</returns>
        public Boolean IsSetDeliveryMethod()
        {
            return this.deliveryMethodField.HasValue;

        }


        /// <summary>
        /// Gets and sets the ISPUPostalCode property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ISPUPostalCode")]
        public String ISPUPostalCode
        {
            get { return this.ISPUPostalCodeField ; }
            set { this.ISPUPostalCodeField= value; }
        }



        /// <summary>
        /// Sets the ISPUPostalCode property
        /// </summary>
        /// <param name="ISPUPostalCode">ISPUPostalCode property</param>
        /// <returns>this instance</returns>
        public ListLookupRequest WithISPUPostalCode(String ISPUPostalCode)
        {
            this.ISPUPostalCodeField = ISPUPostalCode;
            return this;
        }



        /// <summary>
        /// Checks if ISPUPostalCode property is set
        /// </summary>
        /// <returns>true if ISPUPostalCode property is set</returns>
        public Boolean IsSetISPUPostalCode()
        {
            return  this.ISPUPostalCodeField != null;

        }


        /// <summary>
        /// Gets and sets the ListId property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ListId")]
        public String ListId
        {
            get { return this.listIdField ; }
            set { this.listIdField= value; }
        }



        /// <summary>
        /// Sets the ListId property
        /// </summary>
        /// <param name="listId">ListId property</param>
        /// <returns>this instance</returns>
        public ListLookupRequest WithListId(String listId)
        {
            this.listIdField = listId;
            return this;
        }



        /// <summary>
        /// Checks if ListId property is set
        /// </summary>
        /// <returns>true if ListId property is set</returns>
        public Boolean IsSetListId()
        {
            return  this.listIdField != null;

        }


        /// <summary>
        /// Gets and sets the ListType property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ListType")]
        public String ListType
        {
            get { return this.listTypeField ; }
            set { this.listTypeField= value; }
        }



        /// <summary>
        /// Sets the ListType property
        /// </summary>
        /// <param name="listType">ListType property</param>
        /// <returns>this instance</returns>
        public ListLookupRequest WithListType(String listType)
        {
            this.listTypeField = listType;
            return this;
        }



        /// <summary>
        /// Checks if ListType property is set
        /// </summary>
        /// <returns>true if ListType property is set</returns>
        public Boolean IsSetListType()
        {
            return this.listTypeField != null;

        }


        /// <summary>
        /// Gets and sets the MerchantId property.
        /// </summary>
        [XmlElementAttribute(ElementName = "MerchantId")]
        public String MerchantId
        {
            get { return this.merchantIdField ; }
            set { this.merchantIdField= value; }
        }



        /// <summary>
        /// Sets the MerchantId property
        /// </summary>
        /// <param name="merchantId">MerchantId property</param>
        /// <returns>this instance</returns>
        public ListLookupRequest WithMerchantId(String merchantId)
        {
            this.merchantIdField = merchantId;
            return this;
        }



        /// <summary>
        /// Checks if MerchantId property is set
        /// </summary>
        /// <returns>true if MerchantId property is set</returns>
        public Boolean IsSetMerchantId()
        {
            return  this.merchantIdField != null;

        }


        /// <summary>
        /// Gets and sets the ProductGroup property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ProductGroup")]
        public String ProductGroup
        {
            get { return this.productGroupField ; }
            set { this.productGroupField= value; }
        }



        /// <summary>
        /// Sets the ProductGroup property
        /// </summary>
        /// <param name="productGroup">ProductGroup property</param>
        /// <returns>this instance</returns>
        public ListLookupRequest WithProductGroup(String productGroup)
        {
            this.productGroupField = productGroup;
            return this;
        }



        /// <summary>
        /// Checks if ProductGroup property is set
        /// </summary>
        /// <returns>true if ProductGroup property is set</returns>
        public Boolean IsSetProductGroup()
        {
            return  this.productGroupField != null;

        }


        /// <summary>
        /// Gets and sets the ProductPage property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ProductPage")]
        public Decimal ProductPage
        {
            get { return this.productPageField.GetValueOrDefault() ; }
            set { this.productPageField= value; }
        }



        /// <summary>
        /// Sets the ProductPage property
        /// </summary>
        /// <param name="productPage">ProductPage property</param>
        /// <returns>this instance</returns>
        public ListLookupRequest WithProductPage(Decimal productPage)
        {
            this.productPageField = productPage;
            return this;
        }



        /// <summary>
        /// Checks if ProductPage property is set
        /// </summary>
        /// <returns>true if ProductPage property is set</returns>
        public Boolean IsSetProductPage()
        {
            return  this.productPageField != null;

        }


        /// <summary>
        /// Gets and sets the ResponseGroup property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ResponseGroup")]
        public List<String> ResponseGroup
        {
            get
            {
                if (this.responseGroupField == null)
                {
                    this.responseGroupField = new List<String>();
                }
                return this.responseGroupField;
            }
            set { this.responseGroupField =  value; }
        }



        /// <summary>
        /// Sets the ResponseGroup property
        /// </summary>
        /// <param name="list">ResponseGroup property</param>
        /// <returns>this instance</returns>
        public ListLookupRequest WithResponseGroup(params String[] list)
        {
            foreach (String item in list)
            {
                ResponseGroup.Add(item);
            }
            return this;
        }          
 


        /// <summary>
        /// Checks of ResponseGroup property is set
        /// </summary>
        /// <returns>true if ResponseGroup property is set</returns>
        public Boolean IsSetResponseGroup()
        {
            return (ResponseGroup.Count > 0);
        }




        /// <summary>
        /// Gets and sets the ReviewSort property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ReviewSort")]
        public String ReviewSort
        {
            get { return this.reviewSortField ; }
            set { this.reviewSortField= value; }
        }



        /// <summary>
        /// Sets the ReviewSort property
        /// </summary>
        /// <param name="reviewSort">ReviewSort property</param>
        /// <returns>this instance</returns>
        public ListLookupRequest WithReviewSort(String reviewSort)
        {
            this.reviewSortField = reviewSort;
            return this;
        }



        /// <summary>
        /// Checks if ReviewSort property is set
        /// </summary>
        /// <returns>true if ReviewSort property is set</returns>
        public Boolean IsSetReviewSort()
        {
            return  this.reviewSortField != null;

        }


        /// <summary>
        /// Gets and sets the Sort property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Sort")]
        public String Sort
        {
            get { return this.sortField ; }
            set { this.sortField= value; }
        }



        /// <summary>
        /// Sets the Sort property
        /// </summary>
        /// <param name="sort">Sort property</param>
        /// <returns>this instance</returns>
        public ListLookupRequest WithSort(String sort)
        {
            this.sortField = sort;
            return this;
        }



        /// <summary>
        /// Checks if Sort property is set
        /// </summary>
        /// <returns>true if Sort property is set</returns>
        public Boolean IsSetSort()
        {
            return  this.sortField != null;

        }




        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            if (IsSetCondition()) {
                xml.Append("<Condition>");
                xml.Append(this.Condition);
                xml.Append("</Condition>");
            }
            if (IsSetDeliveryMethod()) {
                xml.Append("<DeliveryMethod>");
                xml.Append(this.DeliveryMethod);
                xml.Append("</DeliveryMethod>");
            }
            if (IsSetISPUPostalCode()) {
                xml.Append("<ISPUPostalCode>");
                xml.Append(EscapeXML(this.ISPUPostalCode));
                xml.Append("</ISPUPostalCode>");
            }
            if (IsSetListId()) {
                xml.Append("<ListId>");
                xml.Append(EscapeXML(this.ListId));
                xml.Append("</ListId>");
            }
            if (IsSetListType()) {
                xml.Append("<ListType>");
                xml.Append(this.ListType);
                xml.Append("</ListType>");
            }
            if (IsSetMerchantId()) {
                xml.Append("<MerchantId>");
                xml.Append(EscapeXML(this.MerchantId));
                xml.Append("</MerchantId>");
            }
            if (IsSetProductGroup()) {
                xml.Append("<ProductGroup>");
                xml.Append(EscapeXML(this.ProductGroup));
                xml.Append("</ProductGroup>");
            }
            if (IsSetProductPage()) {
                xml.Append("<ProductPage>");
                xml.Append(this.ProductPage);
                xml.Append("</ProductPage>");
            }
            List<String> responseGroupList  =  this.ResponseGroup;
            foreach (String responseGroup in responseGroupList) { 
                xml.Append("<ResponseGroup>");
                xml.Append(responseGroup);
                xml.Append("</ResponseGroup>");
            }	
            if (IsSetReviewSort()) {
                xml.Append("<ReviewSort>");
                xml.Append(EscapeXML(this.ReviewSort));
                xml.Append("</ReviewSort>");
            }
            if (IsSetSort()) {
                xml.Append("<Sort>");
                xml.Append(EscapeXML(this.Sort));
                xml.Append("</Sort>");
            }
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}